package org.aspire.data;

import org.aspire.core.sys.GameException;
import org.aspire.graphics.Color;
import org.aspire.graphics.DrawGraphics;
import org.aspire.graphics.Frame;

/******************************************************************************
 * An object that renders data to the screen. This include both graphical and
 * audio data.
 * 
 * @author JPACarabuena
 *****************************************************************************/
public interface Renderer {

	// ========================================================================
	// Final Fields
	// ========================================================================
	
	// ========================================================================
	// Getters & Setters
	// ========================================================================
	
	/**************************************************************************
	 * Get the current owner of this renderer.
	 * 
	 * @return the owner of this renderer.
	 *************************************************************************/
	public Owner getOwner();
	
	/**************************************************************************
	 * Retrieve the current graphics renderer.
	 * 
	 * @return	the graphics renderer.
	 *************************************************************************/
	public DrawGraphics getGraphicsRenderer();
	
	/**************************************************************************
	 * Retrieve the current audio renderer.
	 * 
	 * @return	the audio renderer.
	 *************************************************************************/
	public Object getAudioRenderer();
	
	/**************************************************************************
	 * Change the owner of this renderer to the specified new owner.
	 * 
	 * @param owner the new owner of this renderer.
	 *************************************************************************/
	public void setOwner(Owner owner);
	
	/**************************************************************************
	 * Sets the graphics renderer to the specified graphics renderer.
	 * 
	 * @param graphics	the new graphics renderer.
	 *************************************************************************/
	public void setGraphicsRenderer(DrawGraphics graphics);

	public void setColor(Color color);
	
	/**************************************************************************
	 * Sets the audio renderer to the specified audio renderer.
	 * 
	 * @param object	the new audio renderer.
	 *************************************************************************/
	public void setAudioRenderer(Object object);
	
	// ========================================================================
	// Override Methods
	// ========================================================================
	
	// ========================================================================
	// Methods
	// ========================================================================
	
	/**************************************************************************
	 * Draw a line starting from the specified x1 and y1 points up to the
	 * specified x2 and y2 points.
	 * 
	 * @param x1	the first x coordinate.
	 * @param y1	the first y coordinate.
	 * @param x2	the second x coordinate.
	 * @param y2	the second y coordinate.
	 *************************************************************************/
	public void drawLine(int x1, int y1, int x2, int y2);
	
	/**************************************************************************
	 * Draw a rectangle at the specified location with the specified dimension.
	 * 
	 * @param x	the 	x-coordinate of the rectangle.
	 * @param y	the 	y-coordinate of the rectangle.
	 * @param width		the width of the rectangle.
	 * @param height	the height of the rectangle.
	 *************************************************************************/
	public void drawRect(int x, int y, int width, int height);
	
	/**************************************************************************
	 * Draw a rectangle at the specified location with the specified dimension.
	 * It fills the area occupied by the rectangle with the current color of
	 * the graphics renderer.
	 * 
	 * @param x			x-coordinate of the rectangle.
	 * @param y			y-coordinate of the rectangle.
	 * @param width		the width of the rectangle.
	 * @param height	the height of the rectangle.
	 *************************************************************************/
	public void fillRect(int x, int y, int width, int height);
	
	/**************************************************************************
	 * Draw an oval that fits inside the specified rectangle.
	 * 
	 * @param x			x-coordinate of the rectangle.
	 * @param y			y-coordinate of the rectangle.
	 * @param width		the width of the rectangle.
	 * @param height	the height of the rectangle.
	 *************************************************************************/
	public void drawOval(int x, int y, int width, int height);
	
	/**************************************************************************
	 * Draw an oval that fits inside the specified rectangle. It fills the area
	 * occupied by the rectangle with the current color of the graphics
	 * renderer.
	 * 
	 * @param x			x-coordinate of the rectangle.
	 * @param y			y-coordinate of the rectangle.
	 * @param width		the width of the rectangle.
	 * @param height	the height of the rectangle.
	 *************************************************************************/
	public void fillOval(int x, int y, int width, int height);
	
	/**************************************************************************
	 * Draw a closed polygon from the specified x and y coordinates. It might
	 * throw an exception if the specified points does not form a closed
	 * polygon or the number of points specified does not match the actual
	 * number of points.
	 * 
	 * @param xPoints	the x-coordinates of the polygon.
	 * @param yPoints	the y-coordinates of the polygon.
	 * @param nPoints	the number of points of the polygon.
	 * @throws GameException 
	 * 					An exception triggered by formation of unclosed polygon
	 * 					or mismatch in the number of expected and actual
	 * 					vertices.
	 *************************************************************************/
	public void drawPolygon(int[] xPoints, int[] yPoints,
			int nPoints) throws GameException;
	
	/**************************************************************************
	 * Draw a closed polygon from the specified x and y coordinates. It might
	 * throw an exception if the specified points does not form a closed
	 * polygon or the number of points specified does not match the actual
	 * number of points. It fills the area occupied by the polygon with the
	 * current color of the graphics renderer.
	 * 
	 * @param xPoints	the x-coordinates of the polygon.
	 * @param yPoints	the y-coordinates of the polygon.
	 * @param nPoints	the number of points of the polygon.
	 * @throws GameException
	 * 					An exception triggered by formation of unclosed polygon
	 * 					or mismatch in the number of expected and actual
	 * 					vertices.
	 *************************************************************************/
	public void fillPolygon(int[] xPoints, int[] yPoints,
			int nPoints) throws GameException;
	
	/**************************************************************************
	 * Draw the specified string at the specified location with the current
	 * font of the graphics renderer.
	 * 
	 * @param str	the string to be drawn.
	 * @param x		the x-coordinate of the string.
	 * @param y		the y-coordinate of the string.
	 *************************************************************************/
	public void drawString(String str, int x, int y);
	
	/**************************************************************************
	 * Draw the specified image at the specified location.
	 * @param image TODO
	 * @param x		the x-coordinate of the image.
	 * @param y		the y-coordinate of the image.
	 *************************************************************************/
	public void drawImage(Frame image, int x, int y);
	
	/**************************************************************************
	 * Plays the music at the specified path or name. A music is usually an
	 * audio file with <i>*.midi</i> as file extension.
	 *  
	 * @param str	the name or the path of the audio file.
	 *************************************************************************/
	public void playMusic(String str);
	
	/**************************************************************************
	 * Plays the sound at the specified path or name. A sound is usually an
	 * audio file with <i>*.wav</i> as file extension.
	 * 
	 * @param str	the name or the path of the audio file.
	 *************************************************************************/
	public void playSound(String str);
	
	// ========================================================================
	// Inner & Anonymous Classes
	// ========================================================================
}